{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 开始使用 ONNX IR\n",
    "\n",
    "ONNX IR 与 ONNX Script 包一起提供，可以通过 `onnxscript.ir` 获取。要从 ONNX 文件创建 `IR` 对象，将其加载为 `ModelProto` 并调用 `ir.from_proto()` 或 `ir.serde.deserialize_model`：\n",
    "\n",
    "参考：[ONNX IR 快速上手](https://microsoft.github.io/onnxscript/intermediate_representation/index.html)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Define an example model for this example\n",
    "MODEL_TEXT = r\"\"\"\n",
    "<\n",
    "   ir_version: 8,\n",
    "   opset_import: [\"\" : 18],\n",
    "   producer_name: \"pytorch\",\n",
    "   producer_version: \"2.0.0\"\n",
    ">\n",
    "torch_jit (float[5,5,5] input_0) => (float[5,5] val_19, float[5,5] val_6) {\n",
    "   val_1 = Constant <value_int: ints = [1]> ()\n",
    "   val_2 = Shape <start: int = 0> (val_1)\n",
    "   val_3 = Size (val_2)\n",
    "   val_4 = Constant <value: tensor = int64 {0}> ()\n",
    "   val_5 = Equal (val_3, val_4)\n",
    "   val_6 = ReduceMean <keepdims: int = 0, noop_with_empty_axes: int = 0> (input_0, val_1)\n",
    "   val_7 = ReduceMean <keepdims: int = 1, noop_with_empty_axes: int = 0> (input_0, val_1)\n",
    "   val_8 = Shape <start: int = 0> (input_0)\n",
    "   val_9 = Gather <axis: int = 0> (val_8, val_1)\n",
    "   val_10 = ReduceProd <keepdims: int = 0, noop_with_empty_axes: int = 0> (val_9)\n",
    "   val_11 = Sub (input_0, val_7)\n",
    "   val_12 = Mul (val_11, val_11)\n",
    "   val_13 = ReduceMean <keepdims: int = 0, noop_with_empty_axes: int = 0> (val_12, val_1)\n",
    "   val_14 = Cast <to: int = 1> (val_10)\n",
    "   val_15 = Mul (val_13, val_14)\n",
    "   val_16 = Constant <value: tensor = int64 {1}> ()\n",
    "   val_17 = Sub (val_10, val_16)\n",
    "   val_18 = Cast <to: int = 1> (val_17)\n",
    "   val_19 = Div (val_15, val_18)\n",
    "}\n",
    "\"\"\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import onnx\n",
    "\n",
    "from onnxscript import ir\n",
    "\n",
    "# Load the model as onnx.ModelProto\n",
    "# You can also load the model from a file using onnx.load(\"model.onnx\")\n",
    "model_proto = onnx.parser.parse_model(MODEL_TEXT)\n",
    "\n",
    "# Create an IR object from the model\n",
    "model = ir.serde.deserialize_model(model_proto)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "可以探索 IR 对象："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The main graph has 19 nodes.\n"
     ]
    }
   ],
   "source": [
    "print(f\"The main graph has {len(model.graph)} nodes.\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "输入信息："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[Value('input_0', type=Tensor(FLOAT), shape=[5,5,5], producer=None, index=None)]\n"
     ]
    }
   ],
   "source": [
    "print(model.graph.inputs)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "输出信息："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[Value('val_19', type=Tensor(FLOAT), shape=[5,5], producer=, index=0), Value('val_6', type=Tensor(FLOAT), shape=[5,5], producer=, index=0)]\n"
     ]
    }
   ],
   "source": [
    "print(model.graph.outputs)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "使用第一个输入的节点。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[(Node(name='', domain='', op_type='ReduceMean', inputs=(Value('input_0', type=Tensor(FLOAT), shape=[5,5,5], producer=None, index=None), Value('val_1', type=None, shape=None, producer=, index=0)), attributes=OrderedDict({'keepdims': Attr('keepdims', INT, 0), 'noop_with_empty_axes': Attr('noop_with_empty_axes', INT, 0)}), overload='', outputs=(Value('val_6', type=Tensor(FLOAT), shape=[5,5], producer=, index=0),), version=None, doc_string=None), 0), (Node(name='', domain='', op_type='ReduceMean', inputs=(Value('input_0', type=Tensor(FLOAT), shape=[5,5,5], producer=None, index=None), Value('val_1', type=None, shape=None, producer=, index=0)), attributes=OrderedDict({'keepdims': Attr('keepdims', INT, 1), 'noop_with_empty_axes': Attr('noop_with_empty_axes', INT, 0)}), overload='', outputs=(Value('val_7', type=None, shape=None, producer=, index=0),), version=None, doc_string=None), 0), (Node(name='', domain='', op_type='Shape', inputs=(Value('input_0', type=Tensor(FLOAT), shape=[5,5,5], producer=None, index=None),), attributes=OrderedDict({'start': Attr('start', INT, 0)}), overload='', outputs=(Value('val_8', type=None, shape=None, producer=, index=0),), version=None, doc_string=None), 0), (Node(name='', domain='', op_type='Sub', inputs=(Value('input_0', type=Tensor(FLOAT), shape=[5,5,5], producer=None, index=None), Value('val_7', type=None, shape=None, producer=, index=0)), attributes=OrderedDict(), overload='', outputs=(Value('val_11', type=None, shape=None, producer=, index=0),), version=None, doc_string=None), 0)]\n"
     ]
    }
   ],
   "source": [
    "print(list(model.graph.inputs[0].uses()))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "产生最后一个输出（作为第i个输出）的节点。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "%\"val_6\"<FLOAT,[5,5]> ⬅️ ::ReduceMean(%\"input_0\", %\"val_1\") {keepdims=0, noop_with_empty_axes=0}\n",
      "0\n"
     ]
    }
   ],
   "source": [
    "print(model.graph.outputs[-1].producer())\n",
    "print(model.graph.outputs[-1].index())"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "打印计算图："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "tags": [
     "hide-output"
    ]
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">graph</span><span style=\"font-weight: bold\">(</span>\n",
       "    <span style=\"color: #808000; text-decoration-color: #808000\">name</span>=<span style=\"color: #800080; text-decoration-color: #800080\">torch_jit</span>,\n",
       "    <span style=\"color: #808000; text-decoration-color: #808000\">inputs</span>=<span style=\"font-weight: bold\">(</span>\n",
       "        %<span style=\"color: #008000; text-decoration-color: #008000\">\"input_0\"</span><span style=\"font-weight: bold\">&lt;</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff; font-weight: bold\">FLOAT</span><span style=\"color: #000000; text-decoration-color: #000000\">,</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">[</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">5</span><span style=\"color: #000000; text-decoration-color: #000000\">,</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">5</span><span style=\"color: #000000; text-decoration-color: #000000\">,</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">5</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">]</span><span style=\"color: #000000; text-decoration-color: #000000\">&gt;</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">    </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span><span style=\"color: #000000; text-decoration-color: #000000\">,</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">    </span><span style=\"color: #808000; text-decoration-color: #808000\">outputs</span><span style=\"color: #000000; text-decoration-color: #000000\">=</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">        %</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_19\"</span><span style=\"color: #000000; text-decoration-color: #000000\">&lt;FLOAT,</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">[</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">5</span><span style=\"color: #000000; text-decoration-color: #000000\">,</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">5</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">]</span><span style=\"color: #000000; text-decoration-color: #000000\">&gt;,</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">        %</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_6\"</span><span style=\"color: #000000; text-decoration-color: #000000\">&lt;FLOAT,</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">[</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">5</span><span style=\"color: #000000; text-decoration-color: #000000\">,</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">5</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">]</span><span style=\"color: #000000; text-decoration-color: #000000\">&gt;</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">    </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span><span style=\"color: #000000; text-decoration-color: #000000\">,</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">{</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">     </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span><span style=\"color: #000000; text-decoration-color: #000000\"> |  # :anonymous_no</span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">de:1398</span><span style=\"color: #000000; text-decoration-color: #000000\">32865233744</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">          %</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_1\"</span><span style=\"color: #000000; text-decoration-color: #000000\">&lt;?,?&gt; ⬅️ ::</span><span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">Constant</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">()</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">{</span><span style=\"color: #808000; text-decoration-color: #808000\">value_int</span><span style=\"color: #000000; text-decoration-color: #000000\">=</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">[</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">]}</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">     </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1</span><span style=\"color: #000000; text-decoration-color: #000000\"> |  # :anonymous_no</span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">de:1398</span><span style=\"color: #000000; text-decoration-color: #000000\">32855544752</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">          %</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_2\"</span><span style=\"color: #000000; text-decoration-color: #000000\">&lt;?,?&gt; ⬅️ ::</span><span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">Shape</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #000000; text-decoration-color: #000000\">%</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_1\"</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">{</span><span style=\"color: #808000; text-decoration-color: #808000\">start</span><span style=\"color: #000000; text-decoration-color: #000000\">=</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">}</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">     </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2</span><span style=\"color: #000000; text-decoration-color: #000000\"> |  # :anonymous_no</span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">de:1398</span><span style=\"color: #000000; text-decoration-color: #000000\">32855545328</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">          %</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_3\"</span><span style=\"color: #000000; text-decoration-color: #000000\">&lt;?,?&gt; ⬅️ ::</span><span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">Size</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #000000; text-decoration-color: #000000\">%</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_2\"</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">     </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">3</span><span style=\"color: #000000; text-decoration-color: #000000\"> |  # :anonymous_no</span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">de:1398</span><span style=\"color: #000000; text-decoration-color: #000000\">32855545472</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">          %</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_4\"</span><span style=\"color: #000000; text-decoration-color: #000000\">&lt;?,?&gt; ⬅️ ::</span><span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">Constant</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">()</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">{</span><span style=\"color: #808000; text-decoration-color: #808000\">value</span><span style=\"color: #000000; text-decoration-color: #000000\">=</span><span style=\"color: #800080; text-decoration-color: #800080\">TensorProtoTensor</span><span style=\"color: #000000; text-decoration-color: #000000\">&lt;INT64,</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">[]</span><span style=\"color: #000000; text-decoration-color: #000000\">&gt;</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #808000; text-decoration-color: #808000\">name</span><span style=\"color: #000000; text-decoration-color: #000000\">=</span><span style=\"color: #008000; text-decoration-color: #008000\">''</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)}</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">     </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">4</span><span style=\"color: #000000; text-decoration-color: #000000\"> |  # :anonymous_no</span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">de:1398</span><span style=\"color: #000000; text-decoration-color: #000000\">32855545616</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">          %</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_5\"</span><span style=\"color: #000000; text-decoration-color: #000000\">&lt;?,?&gt; ⬅️ ::</span><span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">Equal</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #000000; text-decoration-color: #000000\">%</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_3\"</span><span style=\"color: #000000; text-decoration-color: #000000\">, %</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_4\"</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">     </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">5</span><span style=\"color: #000000; text-decoration-color: #000000\"> |  # :anonymous_no</span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">de:1398</span><span style=\"color: #000000; text-decoration-color: #000000\">32855545760</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">          %</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_6\"</span><span style=\"color: #000000; text-decoration-color: #000000\">&lt;FLOAT,</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">[</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">5</span><span style=\"color: #000000; text-decoration-color: #000000\">,</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">5</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">]</span><span style=\"color: #000000; text-decoration-color: #000000\">&gt; ⬅️ ::</span><span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">ReduceMean</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #000000; text-decoration-color: #000000\">%</span><span style=\"color: #008000; text-decoration-color: #008000\">\"input_0\"</span><span style=\"color: #000000; text-decoration-color: #000000\">, %</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_1\"</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">{</span><span style=\"color: #808000; text-decoration-color: #808000\">keepdims</span><span style=\"color: #000000; text-decoration-color: #000000\">=</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span><span style=\"color: #000000; text-decoration-color: #000000\">, </span><span style=\"color: #808000; text-decoration-color: #808000\">noop_with_empty_axes</span><span style=\"color: #000000; text-decoration-color: #000000\">=</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">}</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">     </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">6</span><span style=\"color: #000000; text-decoration-color: #000000\"> |  # :anonymous_no</span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">de:1398</span><span style=\"color: #000000; text-decoration-color: #000000\">32855545904</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">          %</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_7\"</span><span style=\"color: #000000; text-decoration-color: #000000\">&lt;?,?&gt; ⬅️ ::</span><span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">ReduceMean</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #000000; text-decoration-color: #000000\">%</span><span style=\"color: #008000; text-decoration-color: #008000\">\"input_0\"</span><span style=\"color: #000000; text-decoration-color: #000000\">, %</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_1\"</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">{</span><span style=\"color: #808000; text-decoration-color: #808000\">keepdims</span><span style=\"color: #000000; text-decoration-color: #000000\">=</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1</span><span style=\"color: #000000; text-decoration-color: #000000\">, </span><span style=\"color: #808000; text-decoration-color: #808000\">noop_with_empty_axes</span><span style=\"color: #000000; text-decoration-color: #000000\">=</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">}</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">     </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">7</span><span style=\"color: #000000; text-decoration-color: #000000\"> |  # :anonymous_no</span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">de:1398</span><span style=\"color: #000000; text-decoration-color: #000000\">32855546048</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">          %</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_8\"</span><span style=\"color: #000000; text-decoration-color: #000000\">&lt;?,?&gt; ⬅️ ::</span><span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">Shape</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #000000; text-decoration-color: #000000\">%</span><span style=\"color: #008000; text-decoration-color: #008000\">\"input_0\"</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">{</span><span style=\"color: #808000; text-decoration-color: #808000\">start</span><span style=\"color: #000000; text-decoration-color: #000000\">=</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">}</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">     </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">8</span><span style=\"color: #000000; text-decoration-color: #000000\"> |  # :anonymous_no</span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">de:1398</span><span style=\"color: #000000; text-decoration-color: #000000\">32855546192</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">          %</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_9\"</span><span style=\"color: #000000; text-decoration-color: #000000\">&lt;?,?&gt; ⬅️ ::</span><span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">Gather</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #000000; text-decoration-color: #000000\">%</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_8\"</span><span style=\"color: #000000; text-decoration-color: #000000\">, %</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_1\"</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">{</span><span style=\"color: #808000; text-decoration-color: #808000\">axis</span><span style=\"color: #000000; text-decoration-color: #000000\">=</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">}</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">     </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">9</span><span style=\"color: #000000; text-decoration-color: #000000\"> |  # :anonymous_no</span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">de:1398</span><span style=\"color: #000000; text-decoration-color: #000000\">32855546336</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">          %</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_10\"</span><span style=\"color: #000000; text-decoration-color: #000000\">&lt;?,?&gt; ⬅️ ::</span><span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">ReduceProd</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #000000; text-decoration-color: #000000\">%</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_9\"</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">{</span><span style=\"color: #808000; text-decoration-color: #808000\">keepdims</span><span style=\"color: #000000; text-decoration-color: #000000\">=</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span><span style=\"color: #000000; text-decoration-color: #000000\">, </span><span style=\"color: #808000; text-decoration-color: #808000\">noop_with_empty_axes</span><span style=\"color: #000000; text-decoration-color: #000000\">=</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">}</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">    </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">10</span><span style=\"color: #000000; text-decoration-color: #000000\"> |  # :anonymous_no</span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">de:1398</span><span style=\"color: #000000; text-decoration-color: #000000\">32855546480</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">          %</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_11\"</span><span style=\"color: #000000; text-decoration-color: #000000\">&lt;?,?&gt; ⬅️ ::</span><span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">Sub</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #000000; text-decoration-color: #000000\">%</span><span style=\"color: #008000; text-decoration-color: #008000\">\"input_0\"</span><span style=\"color: #000000; text-decoration-color: #000000\">, %</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_7\"</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">    </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">11</span><span style=\"color: #000000; text-decoration-color: #000000\"> |  # :anonymous_no</span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">de:1398</span><span style=\"color: #000000; text-decoration-color: #000000\">32855546624</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">          %</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_12\"</span><span style=\"color: #000000; text-decoration-color: #000000\">&lt;?,?&gt; ⬅️ ::</span><span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">Mul</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #000000; text-decoration-color: #000000\">%</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_11\"</span><span style=\"color: #000000; text-decoration-color: #000000\">, %</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_11\"</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">    </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">12</span><span style=\"color: #000000; text-decoration-color: #000000\"> |  # :anonymous_no</span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">de:1398</span><span style=\"color: #000000; text-decoration-color: #000000\">32855546768</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">          %</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_13\"</span><span style=\"color: #000000; text-decoration-color: #000000\">&lt;?,?&gt; ⬅️ ::</span><span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">ReduceMean</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #000000; text-decoration-color: #000000\">%</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_12\"</span><span style=\"color: #000000; text-decoration-color: #000000\">, %</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_1\"</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">{</span><span style=\"color: #808000; text-decoration-color: #808000\">keepdims</span><span style=\"color: #000000; text-decoration-color: #000000\">=</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span><span style=\"color: #000000; text-decoration-color: #000000\">, </span><span style=\"color: #808000; text-decoration-color: #808000\">noop_with_empty_axes</span><span style=\"color: #000000; text-decoration-color: #000000\">=</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">}</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">    </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">13</span><span style=\"color: #000000; text-decoration-color: #000000\"> |  # :anonymous_no</span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">de:1398</span><span style=\"color: #000000; text-decoration-color: #000000\">32855547056</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">          %</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_14\"</span><span style=\"color: #000000; text-decoration-color: #000000\">&lt;?,?&gt; ⬅️ ::</span><span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">Cast</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #000000; text-decoration-color: #000000\">%</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_10\"</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">{</span><span style=\"color: #808000; text-decoration-color: #808000\">to</span><span style=\"color: #000000; text-decoration-color: #000000\">=</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">}</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">    </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">14</span><span style=\"color: #000000; text-decoration-color: #000000\"> |  # :anonymous_no</span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">de:1398</span><span style=\"color: #000000; text-decoration-color: #000000\">32855547200</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">          %</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_15\"</span><span style=\"color: #000000; text-decoration-color: #000000\">&lt;?,?&gt; ⬅️ ::</span><span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">Mul</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #000000; text-decoration-color: #000000\">%</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_13\"</span><span style=\"color: #000000; text-decoration-color: #000000\">, %</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_14\"</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">    </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">15</span><span style=\"color: #000000; text-decoration-color: #000000\"> |  # :anonymous_no</span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">de:1398</span><span style=\"color: #000000; text-decoration-color: #000000\">32855547632</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">          %</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_16\"</span><span style=\"color: #000000; text-decoration-color: #000000\">&lt;?,?&gt; ⬅️ ::</span><span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">Constant</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">()</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">{</span><span style=\"color: #808000; text-decoration-color: #808000\">value</span><span style=\"color: #000000; text-decoration-color: #000000\">=</span><span style=\"color: #800080; text-decoration-color: #800080\">TensorProtoTensor</span><span style=\"color: #000000; text-decoration-color: #000000\">&lt;INT64,</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">[]</span><span style=\"color: #000000; text-decoration-color: #000000\">&gt;</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #808000; text-decoration-color: #808000\">name</span><span style=\"color: #000000; text-decoration-color: #000000\">=</span><span style=\"color: #008000; text-decoration-color: #008000\">''</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)}</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">    </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">16</span><span style=\"color: #000000; text-decoration-color: #000000\"> |  # :anonymous_no</span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">de:1398</span><span style=\"color: #000000; text-decoration-color: #000000\">32855547776</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">          %</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_17\"</span><span style=\"color: #000000; text-decoration-color: #000000\">&lt;?,?&gt; ⬅️ ::</span><span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">Sub</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #000000; text-decoration-color: #000000\">%</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_10\"</span><span style=\"color: #000000; text-decoration-color: #000000\">, %</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_16\"</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">    </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">17</span><span style=\"color: #000000; text-decoration-color: #000000\"> |  # :anonymous_no</span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">de:1398</span><span style=\"color: #000000; text-decoration-color: #000000\">32855547920</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">          %</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_18\"</span><span style=\"color: #000000; text-decoration-color: #000000\">&lt;?,?&gt; ⬅️ ::</span><span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">Cast</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #000000; text-decoration-color: #000000\">%</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_17\"</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">{</span><span style=\"color: #808000; text-decoration-color: #808000\">to</span><span style=\"color: #000000; text-decoration-color: #000000\">=</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">}</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">    </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">18</span><span style=\"color: #000000; text-decoration-color: #000000\"> |  # :anonymous_no</span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">de:1398</span><span style=\"color: #000000; text-decoration-color: #000000\">32855548064</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">          %</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_19\"</span><span style=\"color: #000000; text-decoration-color: #000000\">&lt;FLOAT,</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">[</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">5</span><span style=\"color: #000000; text-decoration-color: #000000\">,</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">5</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">]</span><span style=\"color: #000000; text-decoration-color: #000000\">&gt; ⬅️ ::</span><span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">Div</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #000000; text-decoration-color: #000000\">%</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_15\"</span><span style=\"color: #000000; text-decoration-color: #000000\">, %</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_18\"</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">    return %</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_19\"</span><span style=\"color: #000000; text-decoration-color: #000000\">&lt;FLOAT,</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">[</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">5</span><span style=\"color: #000000; text-decoration-color: #000000\">,</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">5</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">]</span><span style=\"color: #000000; text-decoration-color: #000000\">&gt;, %</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_6\"</span><span style=\"color: #000000; text-decoration-color: #000000\">&lt;FLOAT,</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">[</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">5</span><span style=\"color: #000000; text-decoration-color: #000000\">,</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">5</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">]</span><span style=\"font-weight: bold\">&gt;</span>\n",
       "<span style=\"font-weight: bold\">}</span>\n",
       "</pre>\n"
      ],
      "text/plain": [
       "\u001b[1;35mgraph\u001b[0m\u001b[1m(\u001b[0m\n",
       "    \u001b[33mname\u001b[0m=\u001b[35mtorch_jit\u001b[0m,\n",
       "    \u001b[33minputs\u001b[0m=\u001b[1m(\u001b[0m\n",
       "        %\u001b[32m\"input_0\"\u001b[0m\u001b[1m<\u001b[0m\u001b[1;95mFLOAT\u001b[0m\u001b[39m,\u001b[0m\u001b[1;39m[\u001b[0m\u001b[1;36m5\u001b[0m\u001b[39m,\u001b[0m\u001b[1;36m5\u001b[0m\u001b[39m,\u001b[0m\u001b[1;36m5\u001b[0m\u001b[1;39m]\u001b[0m\u001b[39m>\u001b[0m\n",
       "\u001b[39m    \u001b[0m\u001b[1;39m)\u001b[0m\u001b[39m,\u001b[0m\n",
       "\u001b[39m    \u001b[0m\u001b[33moutputs\u001b[0m\u001b[39m=\u001b[0m\u001b[1;39m(\u001b[0m\n",
       "\u001b[39m        %\u001b[0m\u001b[32m\"val_19\"\u001b[0m\u001b[39m<FLOAT,\u001b[0m\u001b[1;39m[\u001b[0m\u001b[1;36m5\u001b[0m\u001b[39m,\u001b[0m\u001b[1;36m5\u001b[0m\u001b[1;39m]\u001b[0m\u001b[39m>,\u001b[0m\n",
       "\u001b[39m        %\u001b[0m\u001b[32m\"val_6\"\u001b[0m\u001b[39m<FLOAT,\u001b[0m\u001b[1;39m[\u001b[0m\u001b[1;36m5\u001b[0m\u001b[39m,\u001b[0m\u001b[1;36m5\u001b[0m\u001b[1;39m]\u001b[0m\u001b[39m>\u001b[0m\n",
       "\u001b[39m    \u001b[0m\u001b[1;39m)\u001b[0m\u001b[39m,\u001b[0m\n",
       "\u001b[1;39m)\u001b[0m\u001b[39m \u001b[0m\u001b[1;39m{\u001b[0m\n",
       "\u001b[39m     \u001b[0m\u001b[1;36m0\u001b[0m\u001b[39m |  # :anonymous_no\u001b[0m\u001b[1;92mde:1398\u001b[0m\u001b[39m32865233744\u001b[0m\n",
       "\u001b[39m          %\u001b[0m\u001b[32m\"val_1\"\u001b[0m\u001b[39m<?,?> ⬅️ ::\u001b[0m\u001b[1;35mConstant\u001b[0m\u001b[1;39m(\u001b[0m\u001b[1;39m)\u001b[0m\u001b[39m \u001b[0m\u001b[1;39m{\u001b[0m\u001b[33mvalue_int\u001b[0m\u001b[39m=\u001b[0m\u001b[1;39m[\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;39m]\u001b[0m\u001b[1;39m}\u001b[0m\n",
       "\u001b[39m     \u001b[0m\u001b[1;36m1\u001b[0m\u001b[39m |  # :anonymous_no\u001b[0m\u001b[1;92mde:1398\u001b[0m\u001b[39m32855544752\u001b[0m\n",
       "\u001b[39m          %\u001b[0m\u001b[32m\"val_2\"\u001b[0m\u001b[39m<?,?> ⬅️ ::\u001b[0m\u001b[1;35mShape\u001b[0m\u001b[1;39m(\u001b[0m\u001b[39m%\u001b[0m\u001b[32m\"val_1\"\u001b[0m\u001b[1;39m)\u001b[0m\u001b[39m \u001b[0m\u001b[1;39m{\u001b[0m\u001b[33mstart\u001b[0m\u001b[39m=\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;39m}\u001b[0m\n",
       "\u001b[39m     \u001b[0m\u001b[1;36m2\u001b[0m\u001b[39m |  # :anonymous_no\u001b[0m\u001b[1;92mde:1398\u001b[0m\u001b[39m32855545328\u001b[0m\n",
       "\u001b[39m          %\u001b[0m\u001b[32m\"val_3\"\u001b[0m\u001b[39m<?,?> ⬅️ ::\u001b[0m\u001b[1;35mSize\u001b[0m\u001b[1;39m(\u001b[0m\u001b[39m%\u001b[0m\u001b[32m\"val_2\"\u001b[0m\u001b[1;39m)\u001b[0m\n",
       "\u001b[39m     \u001b[0m\u001b[1;36m3\u001b[0m\u001b[39m |  # :anonymous_no\u001b[0m\u001b[1;92mde:1398\u001b[0m\u001b[39m32855545472\u001b[0m\n",
       "\u001b[39m          %\u001b[0m\u001b[32m\"val_4\"\u001b[0m\u001b[39m<?,?> ⬅️ ::\u001b[0m\u001b[1;35mConstant\u001b[0m\u001b[1;39m(\u001b[0m\u001b[1;39m)\u001b[0m\u001b[39m \u001b[0m\u001b[1;39m{\u001b[0m\u001b[33mvalue\u001b[0m\u001b[39m=\u001b[0m\u001b[35mTensorProtoTensor\u001b[0m\u001b[39m<INT64,\u001b[0m\u001b[1;39m[\u001b[0m\u001b[1;39m]\u001b[0m\u001b[39m>\u001b[0m\u001b[1;39m(\u001b[0m\u001b[33mname\u001b[0m\u001b[39m=\u001b[0m\u001b[32m''\u001b[0m\u001b[1;39m)\u001b[0m\u001b[1;39m}\u001b[0m\n",
       "\u001b[39m     \u001b[0m\u001b[1;36m4\u001b[0m\u001b[39m |  # :anonymous_no\u001b[0m\u001b[1;92mde:1398\u001b[0m\u001b[39m32855545616\u001b[0m\n",
       "\u001b[39m          %\u001b[0m\u001b[32m\"val_5\"\u001b[0m\u001b[39m<?,?> ⬅️ ::\u001b[0m\u001b[1;35mEqual\u001b[0m\u001b[1;39m(\u001b[0m\u001b[39m%\u001b[0m\u001b[32m\"val_3\"\u001b[0m\u001b[39m, %\u001b[0m\u001b[32m\"val_4\"\u001b[0m\u001b[1;39m)\u001b[0m\n",
       "\u001b[39m     \u001b[0m\u001b[1;36m5\u001b[0m\u001b[39m |  # :anonymous_no\u001b[0m\u001b[1;92mde:1398\u001b[0m\u001b[39m32855545760\u001b[0m\n",
       "\u001b[39m          %\u001b[0m\u001b[32m\"val_6\"\u001b[0m\u001b[39m<FLOAT,\u001b[0m\u001b[1;39m[\u001b[0m\u001b[1;36m5\u001b[0m\u001b[39m,\u001b[0m\u001b[1;36m5\u001b[0m\u001b[1;39m]\u001b[0m\u001b[39m> ⬅️ ::\u001b[0m\u001b[1;35mReduceMean\u001b[0m\u001b[1;39m(\u001b[0m\u001b[39m%\u001b[0m\u001b[32m\"input_0\"\u001b[0m\u001b[39m, %\u001b[0m\u001b[32m\"val_1\"\u001b[0m\u001b[1;39m)\u001b[0m\u001b[39m \u001b[0m\u001b[1;39m{\u001b[0m\u001b[33mkeepdims\u001b[0m\u001b[39m=\u001b[0m\u001b[1;36m0\u001b[0m\u001b[39m, \u001b[0m\u001b[33mnoop_with_empty_axes\u001b[0m\u001b[39m=\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;39m}\u001b[0m\n",
       "\u001b[39m     \u001b[0m\u001b[1;36m6\u001b[0m\u001b[39m |  # :anonymous_no\u001b[0m\u001b[1;92mde:1398\u001b[0m\u001b[39m32855545904\u001b[0m\n",
       "\u001b[39m          %\u001b[0m\u001b[32m\"val_7\"\u001b[0m\u001b[39m<?,?> ⬅️ ::\u001b[0m\u001b[1;35mReduceMean\u001b[0m\u001b[1;39m(\u001b[0m\u001b[39m%\u001b[0m\u001b[32m\"input_0\"\u001b[0m\u001b[39m, %\u001b[0m\u001b[32m\"val_1\"\u001b[0m\u001b[1;39m)\u001b[0m\u001b[39m \u001b[0m\u001b[1;39m{\u001b[0m\u001b[33mkeepdims\u001b[0m\u001b[39m=\u001b[0m\u001b[1;36m1\u001b[0m\u001b[39m, \u001b[0m\u001b[33mnoop_with_empty_axes\u001b[0m\u001b[39m=\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;39m}\u001b[0m\n",
       "\u001b[39m     \u001b[0m\u001b[1;36m7\u001b[0m\u001b[39m |  # :anonymous_no\u001b[0m\u001b[1;92mde:1398\u001b[0m\u001b[39m32855546048\u001b[0m\n",
       "\u001b[39m          %\u001b[0m\u001b[32m\"val_8\"\u001b[0m\u001b[39m<?,?> ⬅️ ::\u001b[0m\u001b[1;35mShape\u001b[0m\u001b[1;39m(\u001b[0m\u001b[39m%\u001b[0m\u001b[32m\"input_0\"\u001b[0m\u001b[1;39m)\u001b[0m\u001b[39m \u001b[0m\u001b[1;39m{\u001b[0m\u001b[33mstart\u001b[0m\u001b[39m=\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;39m}\u001b[0m\n",
       "\u001b[39m     \u001b[0m\u001b[1;36m8\u001b[0m\u001b[39m |  # :anonymous_no\u001b[0m\u001b[1;92mde:1398\u001b[0m\u001b[39m32855546192\u001b[0m\n",
       "\u001b[39m          %\u001b[0m\u001b[32m\"val_9\"\u001b[0m\u001b[39m<?,?> ⬅️ ::\u001b[0m\u001b[1;35mGather\u001b[0m\u001b[1;39m(\u001b[0m\u001b[39m%\u001b[0m\u001b[32m\"val_8\"\u001b[0m\u001b[39m, %\u001b[0m\u001b[32m\"val_1\"\u001b[0m\u001b[1;39m)\u001b[0m\u001b[39m \u001b[0m\u001b[1;39m{\u001b[0m\u001b[33maxis\u001b[0m\u001b[39m=\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;39m}\u001b[0m\n",
       "\u001b[39m     \u001b[0m\u001b[1;36m9\u001b[0m\u001b[39m |  # :anonymous_no\u001b[0m\u001b[1;92mde:1398\u001b[0m\u001b[39m32855546336\u001b[0m\n",
       "\u001b[39m          %\u001b[0m\u001b[32m\"val_10\"\u001b[0m\u001b[39m<?,?> ⬅️ ::\u001b[0m\u001b[1;35mReduceProd\u001b[0m\u001b[1;39m(\u001b[0m\u001b[39m%\u001b[0m\u001b[32m\"val_9\"\u001b[0m\u001b[1;39m)\u001b[0m\u001b[39m \u001b[0m\u001b[1;39m{\u001b[0m\u001b[33mkeepdims\u001b[0m\u001b[39m=\u001b[0m\u001b[1;36m0\u001b[0m\u001b[39m, \u001b[0m\u001b[33mnoop_with_empty_axes\u001b[0m\u001b[39m=\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;39m}\u001b[0m\n",
       "\u001b[39m    \u001b[0m\u001b[1;36m10\u001b[0m\u001b[39m |  # :anonymous_no\u001b[0m\u001b[1;92mde:1398\u001b[0m\u001b[39m32855546480\u001b[0m\n",
       "\u001b[39m          %\u001b[0m\u001b[32m\"val_11\"\u001b[0m\u001b[39m<?,?> ⬅️ ::\u001b[0m\u001b[1;35mSub\u001b[0m\u001b[1;39m(\u001b[0m\u001b[39m%\u001b[0m\u001b[32m\"input_0\"\u001b[0m\u001b[39m, %\u001b[0m\u001b[32m\"val_7\"\u001b[0m\u001b[1;39m)\u001b[0m\n",
       "\u001b[39m    \u001b[0m\u001b[1;36m11\u001b[0m\u001b[39m |  # :anonymous_no\u001b[0m\u001b[1;92mde:1398\u001b[0m\u001b[39m32855546624\u001b[0m\n",
       "\u001b[39m          %\u001b[0m\u001b[32m\"val_12\"\u001b[0m\u001b[39m<?,?> ⬅️ ::\u001b[0m\u001b[1;35mMul\u001b[0m\u001b[1;39m(\u001b[0m\u001b[39m%\u001b[0m\u001b[32m\"val_11\"\u001b[0m\u001b[39m, %\u001b[0m\u001b[32m\"val_11\"\u001b[0m\u001b[1;39m)\u001b[0m\n",
       "\u001b[39m    \u001b[0m\u001b[1;36m12\u001b[0m\u001b[39m |  # :anonymous_no\u001b[0m\u001b[1;92mde:1398\u001b[0m\u001b[39m32855546768\u001b[0m\n",
       "\u001b[39m          %\u001b[0m\u001b[32m\"val_13\"\u001b[0m\u001b[39m<?,?> ⬅️ ::\u001b[0m\u001b[1;35mReduceMean\u001b[0m\u001b[1;39m(\u001b[0m\u001b[39m%\u001b[0m\u001b[32m\"val_12\"\u001b[0m\u001b[39m, %\u001b[0m\u001b[32m\"val_1\"\u001b[0m\u001b[1;39m)\u001b[0m\u001b[39m \u001b[0m\u001b[1;39m{\u001b[0m\u001b[33mkeepdims\u001b[0m\u001b[39m=\u001b[0m\u001b[1;36m0\u001b[0m\u001b[39m, \u001b[0m\u001b[33mnoop_with_empty_axes\u001b[0m\u001b[39m=\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;39m}\u001b[0m\n",
       "\u001b[39m    \u001b[0m\u001b[1;36m13\u001b[0m\u001b[39m |  # :anonymous_no\u001b[0m\u001b[1;92mde:1398\u001b[0m\u001b[39m32855547056\u001b[0m\n",
       "\u001b[39m          %\u001b[0m\u001b[32m\"val_14\"\u001b[0m\u001b[39m<?,?> ⬅️ ::\u001b[0m\u001b[1;35mCast\u001b[0m\u001b[1;39m(\u001b[0m\u001b[39m%\u001b[0m\u001b[32m\"val_10\"\u001b[0m\u001b[1;39m)\u001b[0m\u001b[39m \u001b[0m\u001b[1;39m{\u001b[0m\u001b[33mto\u001b[0m\u001b[39m=\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;39m}\u001b[0m\n",
       "\u001b[39m    \u001b[0m\u001b[1;36m14\u001b[0m\u001b[39m |  # :anonymous_no\u001b[0m\u001b[1;92mde:1398\u001b[0m\u001b[39m32855547200\u001b[0m\n",
       "\u001b[39m          %\u001b[0m\u001b[32m\"val_15\"\u001b[0m\u001b[39m<?,?> ⬅️ ::\u001b[0m\u001b[1;35mMul\u001b[0m\u001b[1;39m(\u001b[0m\u001b[39m%\u001b[0m\u001b[32m\"val_13\"\u001b[0m\u001b[39m, %\u001b[0m\u001b[32m\"val_14\"\u001b[0m\u001b[1;39m)\u001b[0m\n",
       "\u001b[39m    \u001b[0m\u001b[1;36m15\u001b[0m\u001b[39m |  # :anonymous_no\u001b[0m\u001b[1;92mde:1398\u001b[0m\u001b[39m32855547632\u001b[0m\n",
       "\u001b[39m          %\u001b[0m\u001b[32m\"val_16\"\u001b[0m\u001b[39m<?,?> ⬅️ ::\u001b[0m\u001b[1;35mConstant\u001b[0m\u001b[1;39m(\u001b[0m\u001b[1;39m)\u001b[0m\u001b[39m \u001b[0m\u001b[1;39m{\u001b[0m\u001b[33mvalue\u001b[0m\u001b[39m=\u001b[0m\u001b[35mTensorProtoTensor\u001b[0m\u001b[39m<INT64,\u001b[0m\u001b[1;39m[\u001b[0m\u001b[1;39m]\u001b[0m\u001b[39m>\u001b[0m\u001b[1;39m(\u001b[0m\u001b[33mname\u001b[0m\u001b[39m=\u001b[0m\u001b[32m''\u001b[0m\u001b[1;39m)\u001b[0m\u001b[1;39m}\u001b[0m\n",
       "\u001b[39m    \u001b[0m\u001b[1;36m16\u001b[0m\u001b[39m |  # :anonymous_no\u001b[0m\u001b[1;92mde:1398\u001b[0m\u001b[39m32855547776\u001b[0m\n",
       "\u001b[39m          %\u001b[0m\u001b[32m\"val_17\"\u001b[0m\u001b[39m<?,?> ⬅️ ::\u001b[0m\u001b[1;35mSub\u001b[0m\u001b[1;39m(\u001b[0m\u001b[39m%\u001b[0m\u001b[32m\"val_10\"\u001b[0m\u001b[39m, %\u001b[0m\u001b[32m\"val_16\"\u001b[0m\u001b[1;39m)\u001b[0m\n",
       "\u001b[39m    \u001b[0m\u001b[1;36m17\u001b[0m\u001b[39m |  # :anonymous_no\u001b[0m\u001b[1;92mde:1398\u001b[0m\u001b[39m32855547920\u001b[0m\n",
       "\u001b[39m          %\u001b[0m\u001b[32m\"val_18\"\u001b[0m\u001b[39m<?,?> ⬅️ ::\u001b[0m\u001b[1;35mCast\u001b[0m\u001b[1;39m(\u001b[0m\u001b[39m%\u001b[0m\u001b[32m\"val_17\"\u001b[0m\u001b[1;39m)\u001b[0m\u001b[39m \u001b[0m\u001b[1;39m{\u001b[0m\u001b[33mto\u001b[0m\u001b[39m=\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;39m}\u001b[0m\n",
       "\u001b[39m    \u001b[0m\u001b[1;36m18\u001b[0m\u001b[39m |  # :anonymous_no\u001b[0m\u001b[1;92mde:1398\u001b[0m\u001b[39m32855548064\u001b[0m\n",
       "\u001b[39m          %\u001b[0m\u001b[32m\"val_19\"\u001b[0m\u001b[39m<FLOAT,\u001b[0m\u001b[1;39m[\u001b[0m\u001b[1;36m5\u001b[0m\u001b[39m,\u001b[0m\u001b[1;36m5\u001b[0m\u001b[1;39m]\u001b[0m\u001b[39m> ⬅️ ::\u001b[0m\u001b[1;35mDiv\u001b[0m\u001b[1;39m(\u001b[0m\u001b[39m%\u001b[0m\u001b[32m\"val_15\"\u001b[0m\u001b[39m, %\u001b[0m\u001b[32m\"val_18\"\u001b[0m\u001b[1;39m)\u001b[0m\n",
       "\u001b[39m    return %\u001b[0m\u001b[32m\"val_19\"\u001b[0m\u001b[39m<FLOAT,\u001b[0m\u001b[1;39m[\u001b[0m\u001b[1;36m5\u001b[0m\u001b[39m,\u001b[0m\u001b[1;36m5\u001b[0m\u001b[1;39m]\u001b[0m\u001b[39m>, %\u001b[0m\u001b[32m\"val_6\"\u001b[0m\u001b[39m<FLOAT,\u001b[0m\u001b[1;39m[\u001b[0m\u001b[1;36m5\u001b[0m\u001b[39m,\u001b[0m\u001b[1;36m5\u001b[0m\u001b[1;39m]\u001b[0m\u001b[1m>\u001b[0m\n",
       "\u001b[1m}\u001b[0m\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "model.graph.display(\n",
    "    page=False\n",
    ")  # Set page=True to use a pager in the terminal so long outputs are scrollable"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "将 `IR` 对象转换回 `ModelProto`："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "model_proto_back = ir.serde.serialize_model(model)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "ai",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
